<!-- 
  @name: 加注机地图列表展示
  @date: 2020.3.9
 -->
<template>
	<view class="content">
		<map
			id="theMap"
			style="width: 750rpx; height: 100vh;"
			show-location
			:latitude="latitude"
			:longitude="longitude"
			:markers="markers"
		/>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				markers: [],  //标记点
				markerWd: 28,  //标记点icon宽度
				markerHe: 37.5,  //标记点icon高度
				latitude: 31.839850,  //位置纬度
				longitude: 117.209004,  //位置经度
			}
		},
		onLoad() {
			this.getLocation();
			this.getFillStatin();
		},
		methods: {
			//获取当前位置
			getLocation() {
				uni.getLocation({
				    type: 'gcj02',
				    success: (res) => {
						this.latitude = res.latitude;
						this.longitude = res.longitude;
						
				    }
				});
			},
			//获取周围的加注站
			getFillStatin() {
				this.$http({
					url: this.$api.siteUrl + 'getfillsitepage',
					data: {
						page: 1,
						rows: this.$tmp.ROWS_RET * 5
					}
				}).then(res => {
					let arr = res;
					if(arr && arr.length > 0) {
						this.markers = [];
						let obj = {};
						arr.forEach((item, index) => {
							obj = {};
							obj.id = index + 1;
							obj.width = 48;
							obj.height = 55;
							obj.latitude = parseFloat(item.siteLat);
							obj.longitude = parseFloat(item.siteLng);
							obj.iconPath = this.$tmp.IMG_SITE;
							this.markers.push(obj);
							obj = null;
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	
</style>
